{% extends "base.html" %}
{#{% import "default/_macros.html" as macros %}#}

{% block title %}用户资料 - {{ user.username }}{% endblock %}
{% block content %}
    <div class="container">
        <div class="page-header">
            <h1>{{ user.username }}!</h1>
            {% if user.name or user.location %}
        <p>
            {% if user.name %}
                <img class="img-rounded profile-thumbnail" src="{{ user.gravatar(size=256) }}">
                <p>姓名：{{ user.name }}</p>
            {% endif %}
            {% if user.location %}
                <p>所在位置： <a href="https://www.amap.com/search?query={{ user.location }}">{{ user.location }}</a></p>
            {% endif %}
        </p>
        {% endif %}
        {% if current_user.is_administrator() %}
        <p>联系我：<a href="mailto:{{ user.email }}">{{ user.email }}</a></p>
        {% endif %}
        {% if user.about_me %}<p>{{ user.about_me }}</p>{% endif %}
            <p>
                注册时间：{{ moment(user.member_since).format("YYYY年MM月DD日") }}.
            </p>
            <p>
                最后一次登录时间: {{ moment(user.last_seen).format("YYYY年MM月DD日HH时mm分") }}.
            </p>
        </div>
        <p>{{ user.posts.count() }} 博客文章。</p>
        <p>
            {% if current_user.can(Permission.FOLLOW) and user != current_user %}
                {% if not current_user.is_following(user) %}
                <a href="{{ url_for('.follow', username=user.username) }}" class="btn btn-primary">关注</a>
                {% else %}
                <a href="{{ url_for('.unfollow', username=user.username) }}" class="btn btn-default">取消关注</a>
                {% endif %}
            {% endif %}
            {{ user.username }}
            {{ user.followers.count() }}
            <a href="{{ url_for('.followers', username=user.username) }}">关注者: <span class="badge">{{ user.followers.count() }}</span></a>
            <a href="{{ url_for('.followed_by', username=user.username) }}">关注: <span class="badge">{{ user.followed.count() }}</span></a>
            {% if current_user.is_authenticated and user != current_user and user.is_following(current_user) %}
            | <span class="label label-default">关注你</span>
            {% endif %}
        </p>
        {% if user == current_user %}
            <a class="btn btn-default" href="{{ url_for('.edit_profile') }}">编辑个人资料</a>
        {% endif %}
        {% if current_user.is_administrator() %}
            <a class="btn btn-danger" href="{{ url_for('.edit_profile_admin', id=user.id) }}">编辑个人资料(管理员)</a>
        {% endif %}
        <h3>{{ user.username }}发的帖子</h3>
        {% include 'default/_posts.html' %}
        {# 分页 #}
{#        {% if pagination %}#}
{#            <div class="pagination">#}
{#                {{ macros.pagination_widget(pagination, '.user', username=user.username) }}#}
{#            </div>#}
{#        {% endif pagination %}#}
    </div>
{% endblock content %}